<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        Schema::create('scenic_orders', function (Blueprint $table) {
            $table->id();
            $table->uuid('user_id')->comment('用户id');
            $table->bigInteger('channel_id')->comment('客户端id');
            $table->tinyInteger('trip_type')->default(8)->comment('类型景区门票 8');
            $table->tinyInteger('trip_no')->default(1)->comment('行程序号 - 1 第一程 - 2 第二程');
            $table->string('trip_id',36)->comment('行程业务id 一个行程可能多个订单');
            $table->string('order_sn',36)->comment('系统订单号');
            $table->string('out_order_id',36)->comment('外部服务商订单id');
            $table->string('order_service',20)->comment('订单服务商，tuniu等');
            $table->string('pay_sn',36)->default('')->comment('支付单号,支付成功后更新');
            $table->integer('order_state')->comment('订单状态');
            $table->unsignedDecimal('order_amount', 10, 2)->comment('订单金额');
            $table->unsignedDecimal('provider_pay_amount', 10, 2)->comment('向服务商支付的金额');
            $table->tinyInteger('provider_pay_state')->comment('供应商支付状态 0 待支付 1 已支付 2 无需支付(线下)');
            $table->unsignedTinyInteger('delete_state')->default(0)->comment('删除状态 1 已删除 0 未删除 ');
            $table->string('delete_desc')->default('')->comment('删除描述:手动删除');
            $table->string('mobile', 11)->comment('通知手机号');
            $table->timestamp('deleted_at')->nullable()->comment('删除时间');
            $table->timestamp('provider_pay_at')->nullable()->comment('供应商支付成功时间(预定时间)');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('scenic_orders');
    }
};
